/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package rpt.lib;

import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JTabbedPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

/**
 *
 * @author Roberto
 */
public class CRegistroControleNavegacaoMenuArvoreTab {

    Object fObjetoMenu = null;
    JTree fArvore = null;
    DefaultMutableTreeNode fNodoArvore = null;
    JTabbedPane fTabbedPane = null;
    CTabBotaoFechar fTabBotaoFechar = null;

    public CRegistroControleNavegacaoMenuArvoreTab(JTabbedPane aTabbedPane) {
        super();
        fTabbedPane = aTabbedPane;
    }

    public Object getMenu() {
        return fObjetoMenu;
    }

    public void setMenu(Object aObjetoMenu) {
        fObjetoMenu = aObjetoMenu;
    }

    public JTree getArvore() {
        return fArvore;
    }
/*
    public void setArvore(JTree aArvore) {
        fArvore = aArvore;
    }
*/
    public DefaultMutableTreeNode getNodoArvore() {
        return fNodoArvore;
    }
/*
    public void setNodoArvore(DefaultMutableTreeNode aNodoArvore) {
        fNodoArvore = aNodoArvore;
    }
*/
    public void setNodoArvore(JTree aArvore, DefaultMutableTreeNode aNodoArvore) {
        fArvore = aArvore;
        fNodoArvore = aNodoArvore;
    }
/*
    public JTabbedPane getTabbedPane() {
        return fTabbedPane;
    }

    public void setTabbedPane(JTabbedPane aTabbedPane) {
        fTabbedPane = aTabbedPane;
    }

    public void setTabbedPane(JTabbedPane aTabbedPane, CTabBotaoFechar aTabBotaoFechar) {
        fTabbedPane = aTabbedPane;
        fTabBotaoFechar = aTabBotaoFechar;
    }
*/
    public CTabBotaoFechar getTabBotaoFechar() {
        return fTabBotaoFechar;
    }

    public void setTabBotaoFechar(CTabBotaoFechar aTabBotaoFechar) {
        fTabBotaoFechar = aTabBotaoFechar;
    }

    public void focarTodos() {
        if (fObjetoMenu != null) {
            if (fObjetoMenu instanceof JMenuBar) {
                JMenuBar mb = (JMenuBar)fObjetoMenu;
                mb.requestFocusInWindow();
            }
            else
                if (fObjetoMenu instanceof JMenuItem) {
                    JMenuItem mi = (JMenuItem)fObjetoMenu;
                    mi.requestFocusInWindow();
                }
        }
        if (fNodoArvore != null) {
            TreePath tp = new TreePath(fNodoArvore.getPath());
            fArvore.setSelectionPath(tp);
            fArvore.scrollPathToVisible(tp);
        }
        if ( fTabbedPane != null) {
            //int i = fTabbedPane.getSelectedIndex();
            int j = fTabbedPane.indexOfTabComponent(fTabBotaoFechar);
            //fTabbedPane.setSelectedComponent(fTabBotaoFechar);
            if (j >= 0)
                fTabbedPane.setSelectedIndex(j);
        }
    }
}
